<template>
    <xh-pages :tabBar="true">
        <view class="pages-container">
            <view class="rows">
                <view class="col-2" v-for="item in datalist" @tap="openWin({ url: '/pages/poster/details?id=' + item.classify_id+'&poster_id='+item.id ,type:'redirectTo'})">
                    <view class="tag">
                        <text class="text vip" v-if="item.vip_state">VIP</text>
                        <text class="text" v-else>免费</text>
                    </view>
                    <image :src="item.url" lazy-load mode="scaleToFill" class="poster" />
                </view>
            </view>
        </view>
    </xh-pages>
</template>

<script setup lang="ts">
import { openWin } from '@/utils/helpers'
const datalist = ref<any>([])

const getPosterList = (id: string) => {
    uni.$u.http.post('Poster/posterList', {
        classify_id: id
    }).then((res: any) => {
        if (res?.code == 200) {
            datalist.value = res.data;
        }
    })
}
onLoad((options) => {
    getPosterList(options.id)
})

</script>

<style lang="scss" scoped>
.pages-container {
    background-image: url('@/static/pic_bg_youxi.png');
    background-size: 100% 100%;
    min-height: 100%;
}

.rows {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-gap: 10px;
    padding: 10px;
    --col-height: calc((100vw - 20px) / 2 * 1.5);

    .col-2 {
        height: var(--col-height);
        grid-column: span 1;
        border-radius: 10px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background-color: rgba(255, 255, 255, .5);
        border-radius: 10px;
        drop-filter: blur(10px);
        position: relative;

        .poster {
            width: 100%;
            height: var(--col-height);
            border-radius: 10px;
        }

        .tag {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 100;

            .text {
                font-size: 12px;
                font-weight: 500;
                color: #FFFFFF;
                line-height: 16px;
                text-align: center;
                padding: 2px 10px;
                background-color: rgba(0, 0, 0, .5);
                border-radius: 10px;

                &.vip {
                    background-color: #FF6997;
                }
            }
        }
    }
}
</style>